//用户
import request from '@/utils/request'
import type {RoleList ,RoleData,MenuResponseData} from './type'
enum API {
  ROLELIST_URL = '/admin/acl/role',
  //添加
  ADDROLE_URL = '/admin/acl/role/save',
  // 详情
  DETAILROLE_URL = '/admin/acl/role/get/',
  // 修改
  UPDATEROLE_URL = '/admin/acl/role/update',
  //删除
  DELETETROLE_URL = '/admin/acl/role/remove/',
//   删除角色列表
 ROLEDELETELIST_URL = '/admin/acl/role/batchRemove',
  //获取全部的菜单与按钮的数据
  ALLPERMISSTION = '/admin/acl/permission/toAssign/',
  //给相应的职位分配权限
  SETPERMISTION_URL = '/admin/acl/permission/doAssign/?',
}
export const reqROLEList = (page: number, limit: number, roleName: string) =>
  request.get<any, RoleList>(API.ROLELIST_URL + `/${page}/${limit}?roleName=${roleName}`)

export const reqDeleteROLE = (id: number) =>
  request.delete<any, any>(API.DELETETROLE_URL + id)

export const reqAddROLE = (data: RoleData) => {
  //新增
  return request.post<any, any>(API.ADDROLE_URL, data)
}

//详情
export const reqDetailROLE = (id: number) =>
  request.get<any, any>(API.DETAILROLE_URL + id)

export const reqUpdateROLE = (data: RoleData) => request.put<any, any>(API.UPDATEROLE_URL,data)
export const reqROLEDeleteList = (adminId: number) =>
  request.delete<any, any>(API.ROLEDELETELIST_URL + '/' + adminId)
//获取全部菜单与按钮权限数据
export const reqAllMenuList = (roleId: number) =>
  request.get<any, MenuResponseData>(API.ALLPERMISSTION + roleId)
//给相应的职位下发权限
export const reqSetPermisstion = (roleId: number, permissionId: number[]) =>
  request.post(
    API.SETPERMISTION_URL + `roleId=${roleId}&permissionId=${permissionId}`,
  )